#include "LampProg.h"
#include "camera.h"
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QOpenGLFunctions_3_3_Core>


LampProg::LampProg(QObject *parent)
    : QObject(parent)
    , contex(nullptr)
{}

LampProg::~LampProg()
{
    teardownGL();
}

void LampProg::initializeGL(QOpenGLContext *ctx, void* arg, size_t argLen)
{
    Q_UNUSED(arg)
    Q_UNUSED(argLen)

    contex = ctx;

    if (contex)
        connect(contex, SIGNAL(aboutToBeDestroyed()), SLOT(teardownGL()));
}

void LampProg::setLampColor(const QVector3D &color)
{
     lampColor_ = color;
     emit dataChanged();
}

void LampProg::teardownGL()
{
    if (contex) {
        disconnect(contex, SIGNAL(aboutToBeDestroyed()), this, SLOT(teardownGL()));
        contex = nullptr;
    }
}
